﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using System.Globalization;
using System.Configuration;

namespace Gollie.Service
{
	public class ServiceHelper
	{
		//public static void Sleep(int milliSeconds, int checkCancellationEveryMilliseconds, CancellationToken ct)
		//{
		//	DateTime end = DateTime.Now.AddMilliseconds(milliSeconds);

		//	TimeSpan toGo = end - DateTime.Now;
		//	while (toGo.TotalMilliseconds > checkCancellationEveryMilliseconds)
		//	{
		//		ct.ThrowIfCancellationRequested();

		//		Thread.Sleep(checkCancellationEveryMilliseconds);

		//		toGo = end - DateTime.Now;
		//	}
		//	if (end > DateTime.Now)
		//		Thread.Sleep(toGo.Milliseconds);
		//}

		public static void SetCulture()
		{
			SetCulture(ConfigurationManager.AppSettings["culture"]);
		}

		public static void SetCulture(string culture)
		{
			if (culture != null)
				Thread.CurrentThread.CurrentCulture = new CultureInfo(culture);
		}
	}
}
